#ifndef MULTIUARTMANAGER_H
#define MULTIUARTMANAGER_H

#include <vector>
#include <memory>
#include <unordered_map>
#include "UartChannel.h"

class MultiUartManager {
public:
    using ReceiveCallback = UartChannel::ReceiveCallback;
    using StatusCallback = UartChannel::StatusCallback;

    MultiUartManager(size_t maxPorts);
    bool openPort(int portIndex, const std::string& portName, int baudRate);
    void closePort(int portIndex);
    bool sendData(int portIndex, const std::string& data);
    void setReceiveCallback(int portIndex, ReceiveCallback callback);
    void setStatusCallback(int portIndex, StatusCallback callback);
    bool isConnected(int portIndex) const;

private:
    size_t maxPorts;
    std::unordered_map<int, std::unique_ptr<UartChannel>> channels;
    std::mutex mutex;
};

#endif // MULTIUARTMANAGER_H